#-------------------------------------------------------
# Copyright (c) EDesigner
# All rights reserved.
# History:
# 		<Author>	<Time>		<Version>	  <Des>
#      lzlong		2019-1-10	1.0		
#-------------------------------------------------------
PROJECT(EDesigner)

if(USE_DMSKIA_)
ADD_DEFINITIONS(-DUSE_DMSKIA_RENDER_)
endif()

FILE(GLOB ROOT_HEADER 									inc/*h;inc/*.rc)
FILE(GLOB UI_HEADER       								inc/UI/*.h)
FILE(GLOB CORE_HEADER       						    inc/Core/*.h)
FILE(GLOB ZIP_HEADER								    inc/zip/*.h)
FILE(GLOB COMMON_HEADER     							inc/Common/*.h)
FILE(GLOB SKD_HEADER     								inc/sdk/*.h)

FILE(GLOB ROOT_SOURCE 									src/*.cpp;src/*.c)
FILE(GLOB UI_SOURCE       								src/UI/*.cpp;src/UI/*.c)
FILE(GLOB CORE_SOURCE       							src/Core/*.cpp;src/Core/*.c)
FILE(GLOB ZIP_SOURCE       								src/zip/*.cpp;src/zip/*.c)
FILE(GLOB COMMON_SOURCE     							src/Common/*.cpp;src/Common/*.c)
FILE(GLOB RES_FILES										Res/*h;Res/*.rc;Res/*.zip)

if(USE_DMSKIA_)
FILE(GLOB SKIA_RENDER_HEADER							inc/SkiaRender/*.h)
FILE(GLOB SKIA_RENDER_SOURCE							src/SkiaRender/*.cpp)
endif()

SOURCE_GROUP("inc" 								FILES 	${ROOT_HEADER})
SOURCE_GROUP("inc\\UI" 							FILES 	${UI_HEADER})#必须用\\,不能用/
SOURCE_GROUP("inc\\Core" 						FILES 	${CORE_HEADER})
SOURCE_GROUP("inc\\Zip" 						FILES 	${ZIP_HEADER})
SOURCE_GROUP("inc\\Common" 						FILES 	${COMMON_HEADER})
SOURCE_GROUP("inc\\Common\\Template" 			FILES 	${COMMON_TEMPLATE_HEADER})

SOURCE_GROUP("src"								FILES 	${ROOT_SOURCE})
SOURCE_GROUP("src\\UI"							FILES 	${UI_SOURCE})
SOURCE_GROUP("src\\Core"						FILES 	${CORE_SOURCE})
SOURCE_GROUP("src\\Zip"							FILES 	${ZIP_SOURCE})
SOURCE_GROUP("src\\Common" 						FILES 	${COMMON_SOURCE})
SOURCE_GROUP("Res"								FILES	${RES_FILES})

if(USE_DMSKIA_)
SOURCE_GROUP("inc\\SkiaRender"					FILES	${SKIA_RENDER_HEADER})
SOURCE_GROUP("src\\SkiaRender"					FILES	${SKIA_RENDER_SOURCE})
endif()

use_precompiled_header(GPlatform
   "${CMAKE_CURRENT_SOURCE_DIR}/inc/StdAfx.h"
   "${CMAKE_CURRENT_SOURCE_DIR}/src/StdAfx.cpp"
  )
  
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/
					${CMAKE_CURRENT_SOURCE_DIR}/inc
					${CMAKE_CURRENT_SOURCE_DIR}/inc/UI
					${CMAKE_CURRENT_SOURCE_DIR}/inc/Core
					${CMAKE_CURRENT_SOURCE_DIR}/inc/zip
					${CMAKE_CURRENT_SOURCE_DIR}/inc/Common
					${CMAKE_CURRENT_SOURCE_DIR}/inc/SkiaRender
					${CMAKE_CURRENT_SOURCE_DIR}/Res					
					${ED_SOURCE_DIR}/3rdParty/sdk/include
					${ED_SOURCE_DIR}/3rdParty/sdk/include/core/include
					${ED_SOURCE_DIR}/3rdParty/sdk/include/interface/venus
					${ED_SOURCE_DIR}/3rdParty/sdk/include/third/concurrentqueue
					${ED_SOURCE_DIR}/3rdParty/sdk/include/third/glew-1.9.0-win32/include)

INCLUDE_DIRECTORIES(${ED_SOURCE_DIR}/Modules/DmMain/inc
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Common
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Common/ActiveX
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Common/Template
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Core
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Core/Msg
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Core/Dui
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Core/Event
					${ED_SOURCE_DIR}/Modules/DmMain/inc/IDmMain
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Modules
					${ED_SOURCE_DIR}/Modules/DmMain/inc/Widgets)
					
INCLUDE_DIRECTORIES(${ED_SOURCE_DIR}/Modules/EDBase/inc
					${ED_SOURCE_DIR}/Modules/EDBase/inc/Common
					${ED_SOURCE_DIR}/Modules/EDBase/inc/Common/Template
					${ED_SOURCE_DIR}/Modules/EDBase/inc/Event
					${ED_SOURCE_DIR}/Modules/EDBase/inc/json
					${ED_SOURCE_DIR}/Modules/EDBase/inc/Crash)

#INCLUDE_DIRECTORIES(${ED_SOURCE_DIR}/Modules/EDCore/inc
#					${ED_SOURCE_DIR}/Modules/EDCore/inc/common
#					${ED_SOURCE_DIR}/Modules/EDCore/inc/document)
					
INCLUDE_DIRECTORIES(${ED_SOURCE_DIR}/3rdParty/json)
INCLUDE_DIRECTORIES(${ED_SOURCE_DIR}/3rdParty/zlib)

# 引用skia的头文件
if(USE_DMSKIA_)
INCLUDE_DIRECTORIES(${ED_SOURCE_DIR}/3rdParty/skia;
					${ED_SOURCE_DIR}/3rdParty/skia/inc/config;
					${ED_SOURCE_DIR}/3rdParty/skia/inc;
					${ED_SOURCE_DIR}/3rdParty/skia/inc/core;
					)
endif()

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")

ADD_DEFINITIONS(-DUNICODE -D_UNICODE)  # unicode版本
#ADD_DEFINITIONS(-DZLIB_WINAPI)      #使用zlib需要这个宏定义，否则编译会有符号问题
if (CMAKE_BUILD_TYPE STREQUAL Debug)
    ADD_DEFINITIONS(-D_DEBUG)
endif ()

ADD_DEFINITIONS(-D_PLATFORM_WINDOWS)

LINK_DIRECTORIES(${ED_SOURCE_DIR}/3rdParty/sdk/lib/${CMAKE_BUILD_TYPE})
 
 if(USE_DMSKIA_)
 ADD_EXECUTABLE(EDesigner  WIN32 
						  ${ROOT_HEADER}
						  ${UI_HEADER}
						  ${CORE_HEADER}
						  ${ZIP_HEADER}
						  ${COMMON_HEADER}
						  ${COMMON_TEMPLATE_HEADER}
						  ${SKIA_RENDER_HEADER}
						  
						  ${ROOT_SOURCE}
						  ${UI_SOURCE}
						  ${CORE_SOURCE}
						  ${ZIP_SOURCE}
						  ${COMMON_SOURCE}
						  ${RES_FILES}
						  ${SKIA_RENDER_SOURCE}
						  )
else()
ADD_EXECUTABLE(EDesigner  WIN32 
						  ${ROOT_HEADER}
						  ${UI_HEADER}
						  ${CORE_HEADER}
						  ${ZIP_HEADER}
						  ${COMMON_HEADER}
						  ${COMMON_TEMPLATE_HEADER}
						  
						  ${ROOT_SOURCE}
						  ${UI_SOURCE}
						  ${CORE_SOURCE}
						  ${ZIP_SOURCE}
						  ${COMMON_SOURCE}
						  ${RES_FILES}
						  )
endif()
						  
SET_TARGET_PROPERTIES(EDesigner PROPERTIES OUTPUT_NAME "EDesigner")

#增加事件后命令
add_custom_command(TARGET EDesigner 
					PRE_BUILD 
					COMMAND call ${ED_SOURCE_DIR}/Tools/CMake/PreBuild-EDesigner.cmd $(TargetDir) $(Configuration)
					COMMENT "This command will be executed before build target EDesigner"
					)
add_custom_command(TARGET EDesigner 
					POST_BUILD 
					COMMAND call ${ED_SOURCE_DIR}/Tools/CMake/PostBuild.cmd $(TargetDir)
					COMMAND call ${ED_SOURCE_DIR}/Tools/CMake/PostBuild-SDK.cmd $(TargetDir) $(Configuration)
					COMMENT "This command will be executed after build target EDesigner"
					)

add_dependencies(EDesigner  DmMain)
add_dependencies(EDesigner  EDBase)
#add_dependencies(EDesigner  EDCore)
add_dependencies(EDesigner  zlib)

if(USE_DMSKIA_)
	add_dependencies(EDesigner  skia)
	TARGET_LINK_LIBRARIES(EDesigner  Usp10.lib;Opengl32.lib)
endif()
